import { Link } from '@brillout/docpress'
import { ImplementedBy } from '../../components'

Environment: server, client.
<ImplementedBy by={<code>vike-vue</code>} noCustomGuide={true}>`onCreateApp()`</ImplementedBy>

The `onCreateApp()` hook is called right after the
[Vue app](https://vuejs.org/guide/essentials/application.html) is created, giving you the opportunity to extend it,
typically for registering a [Vue plugin](https://vuejs.org/guide/reusability/plugins.html).

```js
// /pages/+onCreateApp.js
// Environment: server, client

export { onCreateApp }

import SomeVuePlugin from 'some-vue-plugin'

const onCreateApp = (pageContext) => {
  const { app } = pageContext
  app.use(SomeVuePlugin)
}
```

## Examples

See [`vike-vue` > /examples/full/pages/+onCreateApp.ts](https://github.com/vikejs/vike-vue/blob/main/examples/full/pages/%2BonCreateApp.ts)

## TypeScript

```ts
// /pages/+onCreateApp.ts
// Environment: server, client

export { onCreateApp }

import type { OnCreateAppSync } from 'vike-vue'
import SomeVuePlugin from 'some-vue-plugin'

const onCreateApp: OnCreateAppSync = (pageContext): ReturnType<OnCreateAppSync> => {
  const { app } = pageContext
  app.use(SomeVuePlugin)
}
```
